package cn.curtain.girl.controller;

import cn.curtain.girl.properties.GirlProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(value = "/hello")
public class HelloController {

    @Autowired
    private GirlProperties girlProperties;
//    @Value("${cupSize}")
//    private String cupSize;
//
//    @Value("${age}")
//    private Integer age;
//
//    @Value("${content}")
//    private String content;

//    @RequestMapping(value={"/say","/hi"},method= RequestMethod.POST)
//    public String say(){
//        return girlProperties.getCupSize()+girlProperties.getAge();
//    }

    @RequestMapping(value={"/say"},method= RequestMethod.GET)
    //等价于    @GetMapping(value = "/say")

    //value="id":表示要获取的值   required:表示是否必传 defaultValue:表示默认值
    public String say(@RequestParam(value = "id", required = false, defaultValue = "0") Integer id){
        return "id:"+id;
//        return girlProperties.getCupSize()+girlProperties.getAge();
    }
}

//获取url中的值   http://127.0.0.1:8081/hello/say/100   获取say后的数据
//value={"/say/{id}"}
//@PathVariable("id")

//获取请求参数中的值  http://127.0.0.1:8081/hello/say?id=100  获取（？id=值）
//value={"/say"}
//@RequestParam("id")